import 'package:f200/common/index.dart';
import 'package:f200/system/index/controllers/index_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class IndexScaffoldView extends GetView<IndexController> {
  const IndexScaffoldView({super.key});

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: KeepAliveWrapper(
          child: PageView(
            physics: const NeverScrollableScrollPhysics(),
            controller: controller.pageController,
            children: controller.pages,
          ),
        ),
        bottomNavigationBar: Obx(() => _buildBottomNavigationBar()),
      ),
    );
  }

  Widget _buildBottomNavigationBar() {
    return BottomNavigationBar(
      elevation: 8.0,
      type: BottomNavigationBarType.fixed,
      currentIndex: controller.currentIndex.value,
      items: const [
        BottomNavigationBarItem(icon: Icon(CmIcons.home), label: "首页"),
        BottomNavigationBarItem(icon: Icon(CmIcons.list), label: "分类"),
        BottomNavigationBarItem(icon: Icon(CmIcons.message), label: "消息"),
        BottomNavigationBarItem(icon: Icon(CmIcons.cart), label: "购物车"),
        BottomNavigationBarItem(icon: Icon(CmIcons.my), label: "我的"),
      ],
      fixedColor: Coloors.color_EA4C43,
      onTap: controller.switchPage,
    );
  }
}
